              \\\\   \\\\\\\\\\\\\\\\\\\\//////////////\\\\\
      ||      ||\\\\\\\\\\|\\\\|\\|\\\\\//|/////||////\\\\\\ \
     |      \\|\\\\\\\\\\||\\\\|\\|\\\\///|/////|////\\\\\\\\\\
     ||     \ |\\\\\\\\\\|\\\\\|\\\\\\////|////||///\\\\\\\\\\\\
      |       |\\\\\\\\\|\\\\\\|\|\\\/////|////|///\\\\\\\\\\\\       \
      |      ||\\\\\\\\|\\\\\\\|\|\\\/////|////|//\\\\\\\\\\\\\\\   \\  \
      ||  \\\|\\\\\\\\\|\\\\\\\|\||\\/////|///|//\\\\\\\\\\\\\\\\\     \
       | \\\\|\\\\\\\\|\\\\\\\\|\\|\\/////|///|/\\\\\\\\\\\\\\ \
       |\\\\\|\\\\\\\\\|\\\\\\\|\\\|\/////////|\\\\\\\\\\\\\\\\       \
          \\\|\\\\\\\\\\\\\\\\\\\\\\\/////////|\\\\\\\\\\\\\\
"Todo: suppre\\\\\\\\", permaps/mm\\ms//ing /\\\and \\\\\ se\\h=5\\
let Menu=['1 one','2 two','3mtmmmem,'4 four'] \    \           \
let Menu=['1 one','2 two','3mthmme','4 four'\'5 fi\iiiive',
\'6 siiiiiiix','7 sevennn','8888 sssssssss','\222\222','99ssssss']


let MaxMenuHeight=5
let WinR=&lines
let WinC=&columns
let Spaces=join(map(range(1,100),'"."'),'.')
fun! DispMenu(menu,cursor)
	let cols=len(a:menu)/g:MaxMenuHeight+(len(a:menu)%g:MaxMenuHeight!=0)
	let width=(&columns-1)/cols
	let rem=cols>0? (&columns-1)%cols : 0
	for i in range(0,g:MaxMenuHeight-1)
		let str=''
		for i2 in range(0,cols-1)
			let w=i2<rem? width : width-1
			if i2*g:MaxMenuHeight+i>=len(a:menu)
				break
			endif
			let fmt=a:menu[i2*g:MaxMenuHeight+i]
			if len(fmt)<w
				let str.=fmt.(g:Spaces[0:w-len(fmt)])
			else
				let str.=fmt[0:w-1].' '	
			endif
		endfor
		ec str
	endfor
endfun
fun! ShowMenu(menu,default)
	let cursor=a:default
	let selection=[]
	let asc=getchar()|let let=nr2char(asc)
	call DisplayMenu(a:menu,cursor)
	while asc!=10
		if let==?'j' || asc=="\<F7>"
			let cursor=(cursor+1)%len(a:menu)
		elseif let==?'k' || asc=="\<F6>"
			let cursor=(cursor+len(a:menu)-1)%len(a:menu)
		elseif let==?'x'
			let i=index(selection,cursor)
			if i!=-1
				let selection+=cursor
			else
				call remove(selection,i)
			endif
			let cursor=(cursor+1)%len(a:menu)
		"do number loop
		endif
		call DisplayMenu(a:menu, cursor)
		let asc=getchar()|let let=nr2char(asc)
	endwhile
	return selection	
endfun
